home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / FORTH / FORTHMAC / OLD / TOOLS1 / !Forthmacs.lib.block2file < prev    next >
Text File  |  1996-06-15  |  1KB  |  35 lines

  1. \ btof.fth
  2. \ Convert from block files to stream files.
  3. \
  4. \ Block files contain a sequence of records each with 64
  5. \ upper case characters.
  6. \
  7. \ Stream files contain variable-length lines terminated
  8. \ by a newline character, without trailing blanks.  Characters
  9. \ are lower case.
  10. \
  11. \ btof     \ block-file stream-file  ( -- )
  12. \    Convert block file to stream file
  13. \
  14. \ If your block files contain anything interesting in block 0,
  15. \ comment-out the
  16. \ " pad d# 1024 ifd @ fgets drop " line in btof.
  17.  
  18. : fcr        ( fd -- )
  19.     newline-string rot fputs ;
  20. : 1line-b-f    ( -- end? )  \ True when end of input file
  21.     pad d# 64 ifd @ fgets  ( #gotten)      \ Grab a record
  22.     ?dup
  23.     if    pad swap  -trailing    ( addr len) \ Strip trailing blanks
  24.         2dup lower        ( addr len) \ Change to lower case
  25.         ofd @ fputs        ( )         \ Write to output file
  26.         ofd @ fcr
  27.         false
  28.     else true
  29.     then ;
  30. : btof  \ in-file-name out-file-name ( -- )
  31.     reading  writing
  32.     pad d# 1024 ifd @ fgets drop        \ omit if block 0 is interesting
  33.     begin 1line-b-f until
  34.     ifd @ close  ofd @ close ;
  35.